<?php

namespace app\common\model\xilumarket;

use think\Model;

class TopicAd extends Model
{
    protected $name = 'xilumarket_topic_ad';

    protected $type = [
        'images' => 'array'
    ];

    protected $append = [
        'timerange_text', 'code'
    ];

    public function getCodeAttr($v, $d) {
        return $d['timerange'];
    }

    public static function getTimerangeArray() {
        return [
            'a' => ['08:00', '10:00'],
            'b' => ['10:00', '12:00'],
            'c' => ['12:00', '14:00'],
            'd' => ['14:00', '16:00'],
            'f' => ['16:00', '18:00'],
            'g' => ['18:00', '20:00'],
            'h' => ['20:00', '22:00'],
            'i' => ['22:00', '24:00'],
            'j' => ['24:00', '02:00'],
        ];
    }

    public function getTimerangeTextAttr($value, $data) {
        return self::getTimerangeArray()[$data['timerange']];
    }
}
